<?php
//测试控制器
class Email extends IController{
	public function regis(){
		$this->redirect("regis");
	}
	//激活用户，修改他的状态值
	public function act(){
		$id = $_GET['id'];
		$id = base64_decode($id);
		$arr = array('status'=>1);
		$model = new IModel("b2");
		$model->setData($arr);
		$res = $model->update("id=$id");
		if ($res) {
			$this->redirect("login");
		}

	}
	public function register(){
		$name = IReq::get("name");
		$password = IReq::get("password");
		$email = IReq::get("email");
		$arr = array('name'=>$name,'password'=>$password,'email'=>$email,'status'=>0);
		//实例化表
		$model = new IModel("b2");
		$model->setData($arr);
		$res = $model->add();
		if ($res) {
			//发邮件
			$title = "欢迎注册成为我们网站的会员";

			$url = "http://www.iwebshop.com/index.php/email/act/id/".base64_encode($res);

			$mail = new SendMail();
			$content = "请点击此链接激活加入我们吧！".$url;
			$mail->send($email,$title,$content);
		}
	}
	public function login_do(){
		$name = IReq::get("name");
		$password = IReq::get("password");
		$model = new IModel("b2");
		$res = $model->query("name='$name' and password='$password'");
		$status = $res[0]['status'];
		if ($status==1) {
			echo "登录成功";
		}else{
			echo "您未激活，请去邮箱激活";
		}
	}
}
?>